import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:fluro/fluro.dart';
import './provider/counter.dart';
import './provider/child_category.dart';
import './provider/category_goods_list.dart';
import './provider/details_info.dart';
import './provider/current_index.dart';
import './provider/cart.dart';
import './page/index_page.dart';
import './routes/application.dart';
import './routes/routes.dart';
 
void main() {
  final counter = CounterModel();
  final childCategoryList = ChildCategory();
  final categoryGoodsList = CategoryGoodsListProvider();
  final detaiInfoProvider = DetaiInfoProvider();
  final cartProvider = CartProvider();
  runApp(
    MultiProvider(
      providers: [
        ChangeNotifierProvider.value(value: counter),
        ChangeNotifierProvider.value(value: childCategoryList),
        ChangeNotifierProvider.value(value: categoryGoodsList),
        ChangeNotifierProvider.value(value: detaiInfoProvider),
        ChangeNotifierProvider.value(value: cartProvider),
        ChangeNotifierProvider.value(value: CurrentIndexProvider()),
      ],
      child: MyApp(),
    )
  );
}

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    // 实例化路由
    final router = Router();
    RoutesConfig.configureRoutes(router);
    Application.router = router;

    return Container(
      child: MaterialApp(
        title: '百姓生活+',
        debugShowCheckedModeBanner: false,
        onGenerateRoute: Application.router.generator,
        theme: ThemeData(
          primaryColor: Colors.pink
        ),
        home: IndexPage(),
      )
    );
  }
}